package com.jingdianjichi.exception;

import com.jingdianjichi.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdaptController {
    /**
     * 运行异常捕获
     */
    @ExceptionHandler({RuntimeException.class})
    public Result runtimeException(RuntimeException exception) {
        exception.printStackTrace();
        return Result.fail(exception.getMessage());
    }

    /**
     * 其他异常捕获
     */
    @ExceptionHandler({Exception.class})
    public Result exception(Exception exception) {
        exception.printStackTrace();
        return Result.fail(exception.getMessage());
    }
}